<?php

	require_once('../includes/config.php');
	require_once('../includes/functions.php');
	
	// Retrieve base HTML
	$pageStr = buildStandardPage('Accounts','Accounts');
	
	$content = '';
	
	if(isMobile()){
		$content .= 'Detected Mobile!';
	}
	else{	
		if(true == isLoggedIn()) {
			if(true == isActive()){
				if (false == isAdmin()){ // It's a customer or bank manager (we assume this because we're logged in)
					
					// We'll use $id to retrieve the account info we care about; 
					$id = getID();
					
					$userInfo = getUserInfo($id);
					
					// Build a custom page with the customer's name
					$pageStr = buildStandardPage( $userInfo['firstname'] . '\'s Account','Accounts');
					
					$content .= makeAccountNavBar($id);
					
					// Build a table of all the accounts for the user
					$content .= buildAccountTable($id);
				}
				else {
					$content .= $MUST_BE_BANK_MNGR;
				}
			}
			else{
				$content .= $NOT_ACTIVE_MESSAGE;
			}
		}
		// The user is not logged in.
		else{
		  $content .= $MUST_BE_LOGGED_IN;
		}
	}

	$pageStr = str_Replace('<!--content-->', $content, $pageStr);

	/**
	 * Send the generated HTML to the client's browser
	 */
	echo $pageStr;
?>